package com.wzh.oj.handler;

import lombok.extern.slf4j.Slf4j;

/**
 * @author wzh
 *
 */
@Slf4j
public class MyUncaughtExceptionHandler implements Thread.UncaughtExceptionHandler {
    private static volatile MyUncaughtExceptionHandler myUncaughtExceptionHandler=null;

    @Override
    public void uncaughtException(Thread t, Throwable e) {
        //        业务处理逻辑
      log.error("Exception in thread "+t.getName());
    }

    public static MyUncaughtExceptionHandler getMyUncaughtExceptionHandler(){
        if (myUncaughtExceptionHandler==null){
            synchronized (MyUncaughtExceptionHandler.class){
                if (myUncaughtExceptionHandler==null){
                    myUncaughtExceptionHandler=new MyUncaughtExceptionHandler();
                }
            }
        }
        return myUncaughtExceptionHandler;
    }
}
